#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
#include<cmath>
#include<map>
#include<set>
#include<cstdio>
#include<algorithm>
#define debug(a) cout<<#a<<"="<<a<<endl;
using namespace std;
const int maxn=2e3+100;
typedef long long LL;
inline LL read(){LL x=0,f=1;char ch=getchar();	while (!isdigit(ch)){if (ch=='-') f=-1;ch=getchar();}while (isdigit(ch)){x=x*10+ch-48;ch=getchar();}
return x*f;}
LL ans[maxn],siz[maxn],c[maxn];
LL id[maxn];
bool vis[maxn];
vector<LL>g[maxn];
LL n;
void dfs1(LL u,LL fa){
     siz[u]=1;
     for(LL i=0;i<g[u].size();i++){
         LL v=g[u][i];
         if(v==fa) continue;
         dfs1(v,u);
         siz[u]+=siz[v];
     }
}
void dfs2(LL u,LL fa){
     LL cnt=0;
     for(LL i=1;i<=n;i++){
         if(!vis[i]) cnt++;
         if(cnt==c[u]+1){
            ans[u]=i;vis[i]=true;
            break;
         }
     }
     for(LL i=0;i<g[u].size();i++){
         LL v=g[u][i];
         if(v==fa) continue;
         dfs2(v,u);
     }
}
int main(void){
   cin.tie(0);std::ios::sync_with_stdio(false);
   cin>>n;
   LL root=0;
   for(LL i=1;i<=n;i++){
       LL fa;cin>>fa>>c[i];
       if(fa==0) {root=i;continue;}
       g[fa].push_back(i);
       g[i].push_back(fa);
   }
   dfs1(root,-1);
   for(LL i=1;i<=n;i++){
       if(c[i]>=siz[i]){
          cout<<"NO"<<"\n";return 0;
       }
   }
   dfs2(root,-1);
   cout<<"YES"<<"\n";
   for(LL i=1;i<=n;i++){
       cout<<ans[i]<<" ";
   }
   return 0;
}
